import thunk from "redux-thunk"; // thunk 转换程序
import { createStore, applyMiddleware, combineReducers } from "redux"; //
//导入开发者工具的扩展包
import {composeWithDevTools} from 'redux-devtools-extension'
//导入 reducer 函数
import countReducer from './reducers/countReducer';
import zanReducer from './reducers/zanReducer';
import todoReducer from './reducers/todoReducer';
import heroReducer from './reducers/heroReducer';

//合并 reducer 函数
//合并之后, redux 内部保存的数据, 将『变为一个对象』
// {count: 10, zan: {value: 0}}
let reducer = combineReducers({
  count: countReducer,
  zan: zanReducer,
  todo: todoReducer,
  hero: heroReducer
});

//创建 store 对象.  store 本意『仓库』
let store = createStore(reducer, composeWithDevTools(applyMiddleware(thunk)));

//暴露 store 对象  
// dispatch(increAction(10));   //同步的修改状态
// dispatch(() => {})           //用来异步的修改状态
export default store;